package com.yongninger.activity.shipsments;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.format.DateFormat;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

import com.yongninger.activity.R;
import com.yongninger.adapter.MyCursorAdpter;
import com.yongninger.dao.DBHelper;
import com.yongninger.dao.ShipmentsDao;
import com.yongninger.util.ExportDoc;
import com.yongninger.vo.ClerkInfo;
import com.yongninger.vo.CustomerInfo;
import com.yongninger.vo.ProductVo;
import com.yongninger.vo.ShipmentsInfoVo;
import com.yongninger.vo.ShipmentsVo;

public class ViewActivity extends Activity {
	private ShipmentsDao shipmentsDao;
	private SQLiteDatabase db;
	private String[] arrClerk;
	CustomerInfo[] arrCustomer;
	ShipmentsInfoVo[] arrShipmentsInfoVo;
	List<EditText> editTextList = new ArrayList<EditText>();
	ProductVo[] arrProductInfos;
	ShipmentsVo shipmentsVo;
	//ProductVo productInfoDefault;
	private EditText showDate = null;
	private static final int DATE_DIALOG_ID = 1;

	private static final int SHOW_DATAPICK = 0;

	private int mYear;

	private int mMonth;

	private int mDay;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ships_view);
		db = new DBHelper(getApplicationContext(), "forever", null, 1).getWritableDatabase();
		shipmentsDao = new ShipmentsDao(getApplicationContext());
		Intent intent = getIntent();
		shipmentsVo = (ShipmentsVo) intent.getSerializableExtra("shipmentsVo");
		/**
		 * 日期
		 */
		showDate = (EditText) findViewById(R.id.sdate);
		showDate.setOnClickListener(new DateButtonOnClickListener());
		final Calendar c = Calendar.getInstance();
		mYear = c.get(Calendar.YEAR);
		mMonth = c.get(Calendar.MONTH);
		mDay = c.get(Calendar.DAY_OF_MONTH);
		showDate.setText(shipmentsVo.getSdate());
		/*
		 * 操作员
		 */
		TextView username = (TextView)this.findViewById(R.id.username1);
		username.setText(shipmentsVo.getUsername());
		/*
		 * 往来客户
		 */
		/*List<CustomerInfo> listCustomer = shipmentsDao
				.queryCustomerInfoVo();
		arrCustomer = new CustomerInfo[listCustomer.size()];
		String[] str = new String[listCustomer.size()];
		int positiona = 0;
		for (int i = 0; i < listCustomer.size(); i++) {
			arrCustomer[i] = listCustomer.get(i);
			str[i] = listCustomer.get(i).getCname();
			if (listCustomer.get(i).getCname()
					.equals(shipmentsVo.getScustomer2())) {
				positiona = i;
			}
		}
		// 点击会员选择
		Spinner spinnera = (Spinner) findViewById(R.id.scustomer2);
		// 将可选内容与ArrayAdapter连接起来
		ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(
				ViewActivity.this, android.R.layout.simple_spinner_item,
				str);
		// 设置下拉列表的风格
		adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		// 将adapter 添加到spinner中
		spinnera.setAdapter(adapter1);
		// 设置默认值
		spinnera.setVisibility(View.VISIBLE);
		spinnera.setSelection(positiona);*/
		AutoCompleteTextView completeTextView2= (AutoCompleteTextView)findViewById(R.id.autoCompleteTextView2);
	      completeTextView2.setThreshold(1);
	       MyCursorAdpter adpter2=new MyCursorAdpter(this, null, 2, db);
	      completeTextView2.setAdapter(adpter2);
	      completeTextView2.setText(shipmentsVo.getScustomer2());

	      AutoCompleteTextView completeTextView1= (AutoCompleteTextView)findViewById(R.id.autoCompleteTextView1);
	      completeTextView1.setThreshold(1);
	       MyCursorAdpter adpter1=new MyCursorAdpter(this, null, 2, db);
	      completeTextView1.setAdapter(adpter1);
	      completeTextView1.setText(shipmentsVo.getScustomer1());
	      completeTextView1.setOnFocusChangeListener(new AutoCompleteFocusChangeListener());
	      
		/*
		 * 选择会员区域
		 */
		List<ClerkInfo> listClerk = shipmentsDao.queryClerkInfoVo();
		arrClerk = new String[listClerk.size()];
		int position = 0;
		for (int i = 0; i < listClerk.size(); i++) {
			if (listClerk.get(i).getCname().equals(shipmentsVo.getSclerk())) {
				position = i;
			}
			arrClerk[i] = listClerk.get(i).getCname();
		}
		Spinner spinner = (Spinner) findViewById(R.id.sclerk);
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item, arrClerk);
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		spinner.setAdapter(adapter);
		spinner.setOnItemSelectedListener(new SpinnerSelectedListener());
		spinner.setVisibility(View.VISIBLE);
		spinner.setSelection(position);
		/*
		 * 发货组织选择
		 */
		List<ShipmentsInfoVo> shipmentsInfoVos = shipmentsDao
				.queryShipmentsInfoVo();
		String[] shipInfoArr = new String[shipmentsInfoVos.size()];
		arrShipmentsInfoVo = new ShipmentsInfoVo[shipmentsInfoVos.size()];
		int position1 = 0;
		for (int i = 0; i < shipmentsInfoVos.size(); i++) {
			shipInfoArr[i] = shipmentsInfoVos.get(i).getSname();
			arrShipmentsInfoVo[i] = shipmentsInfoVos.get(i);
			if (shipmentsInfoVos.get(i).getSname()
					.equals(shipmentsVo.getScompany())) {
				position1 = i;
			}
		}
		Spinner spinnerShipInfo = (Spinner) findViewById(R.id.scompany);
		ArrayAdapter<String> adapterShipInfo = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item, shipInfoArr);
		adapterShipInfo
				.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		spinnerShipInfo.setAdapter(adapterShipInfo);
		spinnerShipInfo
				.setOnItemSelectedListener(new SpinnerSelectedListener2());
		spinnerShipInfo.setVisibility(View.VISIBLE);
		spinnerShipInfo.setSelection(position1);
		/*
		 * 产品选择
		 */
		/*List<ProductVo> productInfos = shipmentsDao.queryProductInfoVo();
		String[] productInfoArr = new String[productInfos.size()];
		arrProductInfos = new ProductVo[productInfos.size()];
		int position2 = 0;
		for (int i = 0; i < productInfos.size(); i++) {
			productInfoArr[i] = productInfos.get(i).getPname();
			arrProductInfos[i] = productInfos.get(i);
			if (productInfos.get(i).getPname()
					.equals(shipmentsVo.getSproductname())) {
				position2 = i;
				productInfoDefault = productInfos.get(i);
			}
		}
		Spinner spinnerProductInfo = (Spinner) findViewById(R.id.sproductname);
		ArrayAdapter<String> adapterProductInfo = new ArrayAdapter<String>(
				this, android.R.layout.simple_spinner_item, productInfoArr);
		adapterProductInfo
				.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		spinnerProductInfo.setAdapter(adapterProductInfo);
		spinnerProductInfo
				.setOnItemSelectedListener(new SpinnerSelectedListener3());
		spinnerProductInfo.setVisibility(View.VISIBLE);
		spinnerProductInfo.setSelection(position2);*/
		/*
		 * 除了下拉框之外的其他项进行赋值
		 */
		// 产品名称
		EditText productName = (EditText) findViewById(R.id.sproductname);
		productName.setText(shipmentsVo.getSproductname());
		// 发货编码
		TextView scode = (TextView) findViewById(R.id.scode);
		scode.setText(shipmentsVo.getScode());
		// 产品类型
		EditText sproducttype = (EditText) findViewById(R.id.sproducttype);
		sproducttype.setText(shipmentsVo.getSproducttype());
		// 物流信息
		EditText wuliuinfo = (EditText) findViewById(R.id.wuliuinfo);
		wuliuinfo.setText(shipmentsVo.getWuliuinfo());
		// 产品单价
		EditText sproductprice = (EditText) findViewById(R.id.sproductprice);
		sproductprice.setText(shipmentsVo.getSproductprice());
		// 主数量
		TextView sproductsum1 = (TextView) findViewById(R.id.sproductsum1);
		sproductsum1.setText(shipmentsVo.getSproductsum1());
		// 辅数量
		TextView sproductsum2 = (TextView) findViewById(R.id.sproductsum2);
		sproductsum2.setText(shipmentsVo.getSproductsum2());
		// 总价格
		TextView sproductcount = (TextView) findViewById(R.id.sproductcount);
		sproductcount.setText(shipmentsVo.getSproductcount());
		// 清单
		String[] contentArr = shipmentsVo.getScontent().split(";");
		setContent(contentArr);
		/*
		 * 修改按钮区域
		 */
		Button modifyBtn = (Button) this.findViewById(R.id.modify);
		OnClickListener onClickListener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (update()) {
					Toast.makeText(getApplicationContext(), "修改成功", 2).show();
					// 跳转到查询页面
					Intent intent = new Intent(ViewActivity.this,
							ListActivity.class);
					startActivity(intent);
				} else {
					Toast.makeText(getApplicationContext(), "修改失败", 2).show();
				}
			}
		};
		modifyBtn.setOnClickListener(onClickListener);

		/*
		 * 删除按钮
		 */
		Button deleteBtn = (Button) this.findViewById(R.id.delete);
		OnClickListener onClickListener1 = new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				// 删除
				boolean result = shipmentsDao.deleteShipmentsVo(shipmentsVo
						.getSid());
				if (result) {
					Toast.makeText(getApplicationContext(), "删除成功", 2).show();
					// 跳转到查询页面
					Intent intent = new Intent(ViewActivity.this,
							ListActivity.class);
					startActivity(intent);
				} else {
					Toast.makeText(getApplicationContext(), "删除失败", 2).show();
				}
			}
		};
		deleteBtn.setOnClickListener(onClickListener1);
		/*
		 * 打印按钮
		 */
		Button save1Btn = (Button) this.findViewById(R.id.save1);
		OnClickListener onClickListener2 = new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				// 打印
				// ##################根据Word模板导出单个Word文档###################################################
				Map<String, String> map = new HashMap<String, String>();
				setMap(map);
				TextView scode = (TextView) findViewById(R.id.scode);
				boolean temp = new ExportDoc("yongninger"+scode.getText().toString() + ".doc").export(getApplicationContext(),
						map);
				if (temp) {
					Toast.makeText(getApplicationContext(), "生产文件成功", 2).show();
					// 跳转到查询页面
					Intent intent = new Intent(ViewActivity.this,
							ListActivity.class);
					startActivity(intent);
				} else {
					Toast.makeText(getApplicationContext(), "生产文件失败", 2).show();
				}
				// DOCWriter.searchAndReplace("", "", "");
				// Toast.makeText(getApplicationContext(), "请稍候", 2).show();
			}
		};
		save1Btn.setOnClickListener(onClickListener2);
		/**
		 * 监听文本框值改变
		 */
		setContentListener();
		EditText contentnumsEt = (EditText) findViewById(R.id.contentnums);
		contentnumsEt.setText(shipmentsVo.getContentnums());
		int contentnum = Integer.parseInt(shipmentsVo.getContentnums());
		 if(1<=contentnum && contentnum<= 100){
			 for (int i = 0; i < contentnum; i++) {
				// editTextList.get(i).setEnabled(true);
				 editTextList.get(i).setVisibility(0);
			 } 
			 for (int i = contentnum; i < editTextList.size(); i++) {
				 //editTextList.get(i).setEnabled(false);
				 editTextList.get(i).setVisibility(4);
				 editTextList.get(i).setText(null);
			 }
		 }
	}

	private void setContentListener() {
		// 预计填写数量
				EditText contentnums = (EditText) findViewById(R.id.contentnums);
				contentnums.setOnFocusChangeListener(new contentNumsOnFocusChangeListener());
		// TODO Auto-generated method stub
		EditText content1Et = (EditText) findViewById(R.id.content1);
		content1Et.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content2Et = (EditText) findViewById(R.id.content2);
		content2Et.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content3Et = (EditText) findViewById(R.id.content3);
		content3Et.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content4Et = (EditText) findViewById(R.id.content4);
		content4Et.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content5Et = (EditText) findViewById(R.id.content5);
		content5Et.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content6Et = (EditText) findViewById(R.id.content6);
		content6Et.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content7Et = (EditText) findViewById(R.id.content7);
		content7Et.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content8Et = (EditText) findViewById(R.id.content8);
		content8Et.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content9Et = (EditText) findViewById(R.id.content9);
		content9Et.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content10Et = (EditText) findViewById(R.id.content10);
		content10Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content11Et = (EditText) findViewById(R.id.content11);
		content11Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content12Et = (EditText) findViewById(R.id.content12);
		content12Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content13Et = (EditText) findViewById(R.id.content13);
		content13Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content14Et = (EditText) findViewById(R.id.content14);
		content14Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content15Et = (EditText) findViewById(R.id.content15);
		content15Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content16Et = (EditText) findViewById(R.id.content16);
		content16Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content17Et = (EditText) findViewById(R.id.content17);
		content17Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content18Et = (EditText) findViewById(R.id.content18);
		content18Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content19Et = (EditText) findViewById(R.id.content19);
		content19Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content20Et = (EditText) findViewById(R.id.content20);
		content20Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content21Et = (EditText) findViewById(R.id.content21);
		content21Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content22Et = (EditText) findViewById(R.id.content22);
		content22Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content23Et = (EditText) findViewById(R.id.content23);
		content23Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content24Et = (EditText) findViewById(R.id.content24);
		content24Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content25Et = (EditText) findViewById(R.id.content25);
		content25Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content26Et = (EditText) findViewById(R.id.content26);
		content26Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content27Et = (EditText) findViewById(R.id.content27);
		content27Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content28Et = (EditText) findViewById(R.id.content28);
		content28Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content29Et = (EditText) findViewById(R.id.content29);
		content29Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content30Et = (EditText) findViewById(R.id.content30);
		content30Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content31Et = (EditText) findViewById(R.id.content31);
		content31Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content32Et = (EditText) findViewById(R.id.content32);
		content32Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content33Et = (EditText) findViewById(R.id.content33);
		content33Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content34Et = (EditText) findViewById(R.id.content34);
		content34Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content35Et = (EditText) findViewById(R.id.content35);
		content35Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content36Et = (EditText) findViewById(R.id.content36);
		content36Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content37Et = (EditText) findViewById(R.id.content37);
		content37Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content38Et = (EditText) findViewById(R.id.content38);
		content38Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content39Et = (EditText) findViewById(R.id.content39);
		content39Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content40Et = (EditText) findViewById(R.id.content40);
		content40Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content41Et = (EditText) findViewById(R.id.content41);
		content41Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content42Et = (EditText) findViewById(R.id.content42);
		content42Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content43Et = (EditText) findViewById(R.id.content43);
		content43Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content44Et = (EditText) findViewById(R.id.content44);
		content44Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content45Et = (EditText) findViewById(R.id.content45);
		content45Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content46Et = (EditText) findViewById(R.id.content46);
		content46Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content47Et = (EditText) findViewById(R.id.content47);
		content47Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content48Et = (EditText) findViewById(R.id.content48);
		content48Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content49Et = (EditText) findViewById(R.id.content49);
		content49Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content50Et = (EditText) findViewById(R.id.content50);
		content50Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content51Et = (EditText) findViewById(R.id.content51);
		content51Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content52Et = (EditText) findViewById(R.id.content52);
		content52Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content53Et = (EditText) findViewById(R.id.content53);
		content53Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content54Et = (EditText) findViewById(R.id.content54);
		content54Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content55Et = (EditText) findViewById(R.id.content55);
		content55Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content56Et = (EditText) findViewById(R.id.content56);
		content56Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content57Et = (EditText) findViewById(R.id.content57);
		content57Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content58Et = (EditText) findViewById(R.id.content58);
		content58Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content59Et = (EditText) findViewById(R.id.content59);
		content59Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content60Et = (EditText) findViewById(R.id.content60);
		content60Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content61Et = (EditText) findViewById(R.id.content61);
		content61Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content62Et = (EditText) findViewById(R.id.content62);
		content62Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content63Et = (EditText) findViewById(R.id.content63);
		content63Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content64Et = (EditText) findViewById(R.id.content64);
		content64Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content65Et = (EditText) findViewById(R.id.content65);
		content65Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content66Et = (EditText) findViewById(R.id.content66);
		content66Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content67Et = (EditText) findViewById(R.id.content67);
		content67Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content68Et = (EditText) findViewById(R.id.content68);
		content68Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content69Et = (EditText) findViewById(R.id.content69);
		content69Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content70Et = (EditText) findViewById(R.id.content70);
		content70Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content71Et = (EditText) findViewById(R.id.content71);
		content71Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content72Et = (EditText) findViewById(R.id.content72);
		content72Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content73Et = (EditText) findViewById(R.id.content73);
		content73Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content74Et = (EditText) findViewById(R.id.content74);
		content74Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content75Et = (EditText) findViewById(R.id.content75);
		content75Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content76Et = (EditText) findViewById(R.id.content76);
		content76Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content77Et = (EditText) findViewById(R.id.content77);
		content77Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content78Et = (EditText) findViewById(R.id.content78);
		content78Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content79Et = (EditText) findViewById(R.id.content79);
		content79Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content80Et = (EditText) findViewById(R.id.content80);
		content80Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content81Et = (EditText) findViewById(R.id.content81);
		content81Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content82Et = (EditText) findViewById(R.id.content82);
		content82Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content83Et = (EditText) findViewById(R.id.content83);
		content83Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content84Et = (EditText) findViewById(R.id.content84);
		content84Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content85Et = (EditText) findViewById(R.id.content85);
		content85Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content86Et = (EditText) findViewById(R.id.content86);
		content86Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content87Et = (EditText) findViewById(R.id.content87);
		content87Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content88Et = (EditText) findViewById(R.id.content88);
		content88Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content89Et = (EditText) findViewById(R.id.content89);
		content89Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content90Et = (EditText) findViewById(R.id.content90);
		content90Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content91Et = (EditText) findViewById(R.id.content91);
		content91Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content92Et = (EditText) findViewById(R.id.content92);
		content92Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content93Et = (EditText) findViewById(R.id.content93);
		content93Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content94Et = (EditText) findViewById(R.id.content94);
		content94Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content95Et = (EditText) findViewById(R.id.content95);
		content95Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content96Et = (EditText) findViewById(R.id.content96);
		content96Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content97Et = (EditText) findViewById(R.id.content97);
		content97Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content98Et = (EditText) findViewById(R.id.content98);
		content98Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content99Et = (EditText) findViewById(R.id.content99);
		content99Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		EditText content100Et = (EditText) findViewById(R.id.content100);
		content100Et
				.setOnFocusChangeListener(new contentOnFocusChangeListener());
		editTextList.add(content1Et);
		editTextList.add(content2Et);
		editTextList.add(content3Et);
		editTextList.add(content4Et);
		editTextList.add(content5Et);
		editTextList.add(content6Et);
		editTextList.add(content7Et);
		editTextList.add(content8Et);
		editTextList.add(content9Et);
		editTextList.add(content10Et);
		editTextList.add(content11Et);
		editTextList.add(content12Et);
		editTextList.add(content13Et);
		editTextList.add(content14Et);
		editTextList.add(content15Et);
		editTextList.add(content16Et);
		editTextList.add(content17Et);
		editTextList.add(content18Et);
		editTextList.add(content19Et);
		editTextList.add(content20Et);
		editTextList.add(content21Et);
		editTextList.add(content22Et);
		editTextList.add(content23Et);
		editTextList.add(content24Et);
		editTextList.add(content25Et);
		editTextList.add(content26Et);
		editTextList.add(content27Et);
		editTextList.add(content28Et);
		editTextList.add(content29Et);
		editTextList.add(content30Et);
		editTextList.add(content31Et);
		editTextList.add(content32Et);
		editTextList.add(content33Et);
		editTextList.add(content34Et);
		editTextList.add(content35Et);
		editTextList.add(content36Et);
		editTextList.add(content37Et);
		editTextList.add(content38Et);
		editTextList.add(content39Et);
		editTextList.add(content40Et);
		editTextList.add(content41Et);
		editTextList.add(content42Et);
		editTextList.add(content43Et);
		editTextList.add(content44Et);
		editTextList.add(content45Et);
		editTextList.add(content46Et);
		editTextList.add(content47Et);
		editTextList.add(content48Et);
		editTextList.add(content49Et);
		editTextList.add(content50Et);
		editTextList.add(content51Et);
		editTextList.add(content52Et);
		editTextList.add(content53Et);
		editTextList.add(content54Et);
		editTextList.add(content55Et);
		editTextList.add(content56Et);
		editTextList.add(content57Et);
		editTextList.add(content58Et);
		editTextList.add(content59Et);
		editTextList.add(content60Et);
		editTextList.add(content61Et);
		editTextList.add(content62Et);
		editTextList.add(content63Et);
		editTextList.add(content64Et);
		editTextList.add(content65Et);
		editTextList.add(content66Et);
		editTextList.add(content67Et);
		editTextList.add(content68Et);
		editTextList.add(content69Et);
		editTextList.add(content70Et);
		editTextList.add(content71Et);
		editTextList.add(content72Et);
		editTextList.add(content73Et);
		editTextList.add(content74Et);
		editTextList.add(content75Et);
		editTextList.add(content76Et);
		editTextList.add(content77Et);
		editTextList.add(content78Et);
		editTextList.add(content79Et);
		editTextList.add(content80Et);
		editTextList.add(content81Et);
		editTextList.add(content82Et);
		editTextList.add(content83Et);
		editTextList.add(content84Et);
		editTextList.add(content85Et);
		editTextList.add(content86Et);
		editTextList.add(content87Et);
		editTextList.add(content88Et);
		editTextList.add(content89Et);
		editTextList.add(content90Et);
		editTextList.add(content91Et);
		editTextList.add(content92Et);
		editTextList.add(content93Et);
		editTextList.add(content94Et);
		editTextList.add(content95Et);
		editTextList.add(content96Et);
		editTextList.add(content97Et);
		editTextList.add(content98Et);
		editTextList.add(content99Et);
		editTextList.add(content100Et);
	}
	class contentNumsOnFocusChangeListener implements OnFocusChangeListener{
		 @Override      
		 public void onFocusChange(View v, boolean hasFocus) { 
			 // TODO Auto-generated method stub              
			 if(!hasFocus){
				//得到这个数字
				 EditText contentnums = (EditText) findViewById(R.id.contentnums);
				 int contentnum = Integer.parseInt(contentnums.getText().toString());
				 if(1<=contentnum && contentnum<= 100){
					 for (int i = 0; i < contentnum; i++) {
						// editTextList.get(i).setEnabled(true);
						 editTextList.get(i).setVisibility(0);
					 } 
					 for (int i = contentnum; i < editTextList.size(); i++) {
						 //editTextList.get(i).setEnabled(false);
						 editTextList.get(i).setVisibility(4);
						 editTextList.get(i).setText(null);
					 }
				 }
			 }
		 }
	}
	class contentOnFocusChangeListener implements OnFocusChangeListener {
		@Override
		public void onFocusChange(View v, boolean hasFocus) {
			// TODO Auto-generated method stub
			if (!hasFocus) {
				// 显示客户的联系方式之类的
				//ProductVo productInfo = productInfoDefault;
				// 产品类型
				//TextView sproducttype = (TextView) findViewById(R.id.sproducttype);
				//sproducttype.setText(productInfo.getPtype());
				// 产品单价
				EditText sproductprice = (EditText) findViewById(R.id.sproductprice);
				//sproductprice.setText(productInfo.getPprice());
				String[] content = getContent().split("b;");
				double sum1 = 0;
				double sum2 = 0;
				for (int i = 0; i < content.length; i++) {
					if (null != content[i] && !"".equals(content[i])) {
						sum1 += Double.parseDouble(content[i]);
						sum2++;
					}
				}
				// 主数量
				TextView sproductsum1 = (TextView) findViewById(R.id.sproductsum1);
				sproductsum1.setText(String.valueOf(sum1)
						+ "米");
				// 辅数量
				TextView sproductsum2 = (TextView) findViewById(R.id.sproductsum2);
				sproductsum2.setText(String.valueOf(sum2)
						+ "匹");
				String price = sproductprice.getText().toString();
				if(null!= price && !"".equals(price)){
					// 总价格
					TextView sproductcount = (TextView) findViewById(R.id.sproductcount);
					DecimalFormat df = new DecimalFormat("#.##");
					double count = Double.parseDouble(price) * sum1;
					sproductcount.setText(df.format(count));
				}
			}
		}
	}

	protected void setMap(Map<String, String> map) {
		/*map.put("address1", shipmentsVo.getSaddress());
		List<CustomerInfo> listCustomer = shipmentsDao
				.queryCustomerInfoVo();
		for (int i = 0; i < listCustomer.size(); i++) {
			if(listCustomer.get(i).getCname().equals(shipmentsVo.getScustomer2())){
				map.put("address2", listCustomer.get(i).getCaddress());
			}
		}*/
		map.put("scode", shipmentsVo.getScode());
		map.put("year", shipmentsVo.getSdate().substring(0, 4));
		map.put("month", shipmentsVo.getSdate().substring(4, 6));
		map.put("day", shipmentsVo.getSdate().substring(6, 8));
		map.put("productname", shipmentsVo.getSproductname());
		map.put("num1", shipmentsVo.getSproductsum1());
		map.put("num2", shipmentsVo.getSproductsum2());
		map.put("price", shipmentsVo.getSproductprice());
		map.put("count", shipmentsVo.getSproductcount());
		map.put("customer1", shipmentsVo.getScustomer1());
		map.put("customer2", shipmentsVo.getScustomer2());
		map.put("username", shipmentsVo.getUsername());
		map.put("scode", shipmentsVo.getScode());
		map.put("date", shipmentsVo.getSdate().substring(0, 4) + "年"
				+ shipmentsVo.getSdate().substring(4, 6) + "月" + shipmentsVo.getSdate().substring(6, 8) + "日");
		map.put("sperson", shipmentsVo.getSperson());
		map.put("scontact", shipmentsVo.getScontact());
		map.put("wuliuinfo",shipmentsVo.getWuliuinfo());
		// 清单
		String[] contentArr = shipmentsVo.getScontent().split(";");
		setContent(contentArr, map);
	}

	private void setContent(String[] contentArr, Map<String, String> map) {
		// TODO Auto-generated method stub
		for (int i = 1; i <= contentArr.length; i++) {
			String content1 = contentArr[i - 1];
			String content = content1.replace("b", "");
			switch (i) {
			case 1:
				map.put("c01", content);
				break;
			case 2:
				map.put("c02", content);
				break;
			case 3:
				map.put("c03", content);
				break;
			case 4:
				map.put("c04", content);
				break;
			case 5:
				map.put("c05", content);
				break;
			case 6:
				map.put("c06", content);
				break;
			case 7:
				map.put("c07", content);
				break;
			case 8:
				map.put("c08", content);
				break;
			case 9:
				map.put("c09", content);
				break;
			case 10:
				map.put("c10", content);
				break;
			case 11:
				map.put("c11", content);
				break;
			case 12:
				map.put("c12", content);
				break;
			case 13:
				map.put("c13", content);
				break;
			case 14:
				map.put("c14", content);
				break;
			case 15:
				map.put("c15", content);
				break;
			case 16:
				map.put("c16", content);
				break;
			case 17:
				map.put("c17", content);
				break;
			case 18:
				map.put("c18", content);
				break;
			case 19:
				map.put("c19", content);
				break;
			case 20:
				map.put("c20", content);
				break;
			case 21:
				map.put("c21", content);
				break;
			case 22:
				map.put("c22", content);
				break;
			case 23:
				map.put("c23", content);
				break;
			case 24:
				map.put("c24", content);
				break;
			case 25:
				map.put("c25", content);
				break;
			case 26:
				map.put("c26", content);
				break;
			case 27:
				map.put("c27", content);
				break;
			case 28:
				map.put("c28", content);
				break;
			case 29:
				map.put("c29", content);
				break;
			case 30:
				map.put("c30", content);
				break;
			case 31:
				map.put("c31", content);
				break;
			case 32:
				map.put("c32", content);
				break;
			case 33:
				map.put("c33", content);
				break;
			case 34:
				map.put("c34", content);
				break;
			case 35:
				map.put("c35", content);
				break;
			case 36:
				map.put("c36", content);
				break;
			case 37:
				map.put("c37", content);
				break;
			case 38:
				map.put("c38", content);
				break;
			case 39:
				map.put("c39", content);
				break;
			case 40:
				map.put("c40", content);
				break;
			case 41:
				map.put("c41", content);
				break;
			case 42:
				map.put("c42", content);
				break;
			case 43:
				map.put("c43", content);
				break;
			case 44:
				map.put("c44", content);
				break;
			case 45:
				map.put("c45", content);
				break;
			case 46:
				map.put("c46", content);
				break;
			case 47:
				map.put("c47", content);
				break;
			case 48:
				map.put("c48", content);
				break;
			case 49:
				map.put("c49", content);
				break;
			case 50:
				map.put("c50", content);
				break;
			case 51:
				map.put("c51", content);
				break;
			case 52:
				map.put("c52", content);
				break;
			case 53:
				map.put("c53", content);
				break;
			case 54:
				map.put("c54", content);
				break;
			case 55:
				map.put("c55", content);
				break;
			case 56:
				map.put("c56", content);
				break;
			case 57:
				map.put("c57", content);
				break;
			case 58:
				map.put("c58", content);
				break;
			case 59:
				map.put("c59", content);
				break;
			case 60:
				map.put("c60", content);
				break;
			case 61:
				map.put("c61", content);
				break;
			case 62:
				map.put("c62", content);
				break;
			case 63:
				map.put("c63", content);
				break;
			case 64:
				map.put("c64", content);
				break;
			case 65:
				map.put("c65", content);
				break;
			case 66:
				map.put("c66", content);
				break;
			case 67:
				map.put("c67", content);
				break;
			case 68:
				map.put("c68", content);
				break;
			case 69:
				map.put("c69", content);
				break;
			case 70:
				map.put("c70", content);
				break;
			case 71:
				map.put("c71", content);
				break;
			case 72:
				map.put("c72", content);
				break;
			case 73:
				map.put("c73", content);
				break;
			case 74:
				map.put("c74", content);
				break;
			case 75:
				map.put("c75", content);
				break;
			case 76:
				map.put("c76", content);
				break;
			case 77:
				map.put("c77", content);
				break;
			case 78:
				map.put("c78", content);
				break;
			case 79:
				map.put("c79", content);
				break;
			case 80:
				map.put("c80", content);
				break;
			case 81:
				map.put("c81", content);
				break;
			case 82:
				map.put("c82", content);
				break;
			case 83:
				map.put("c83", content);
				break;
			case 84:
				map.put("c84", content);
				break;
			case 85:
				map.put("c85", content);
				break;
			case 86:
				map.put("c86", content);
				break;
			case 87:
				map.put("c87", content);
				break;
			case 88:
				map.put("c88", content);
				break;
			case 89:
				map.put("c89", content);
				break;
			case 90:
				map.put("c90", content);
				break;
			case 91:
				map.put("c91", content);
				break;
			case 92:
				map.put("c92", content);
				break;
			case 93:
				map.put("c93", content);
				break;
			case 94:
				map.put("c94", content);
				break;
			case 95:
				map.put("c95", content);
				break;
			case 96:
				map.put("c96", content);
				break;
			case 97:
				map.put("c97", content);
				break;
			case 98:
				map.put("c98", content);
				break;
			case 99:
				map.put("c99", content);
				break;
			case 100:
				map.put("c0a", content);
				break;

			}
		}

	}

	/**
	 * @author alex.duan 通过发货组织得到根据发货组织编码 自动生成系统自动生成，建议发货组织简称+年月日+流水码 这个是发货单编码
	 */
	class SpinnerSelectedListener2 implements OnItemSelectedListener {

		public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
				long arg3) {
			ShipmentsInfoVo shipmentsInfoVo = arrShipmentsInfoVo[arg2];
			TextView scode = (TextView) findViewById(R.id.scode);
			String scodess = scode.getText().toString();
			String scodess1 = scodess.substring(scodess.length()-14);
			scode.setText(shipmentsInfoVo.getScode()
					+ scodess1);
		}

		public void onNothingSelected(AdapterView<?> arg0) {
		}
	}

	/**
	 * @author alex.duan 通过商品得到该商品的型号 单价
	 */
	/*class SpinnerSelectedListener3 implements OnItemSelectedListener {

		public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
				long arg3) {
			// 显示客户的联系方式之类的
			ProductVo productInfo = arrProductInfos[arg2];
			productInfoDefault = arrProductInfos[arg2];
			// 产品类型
			TextView sproducttype = (TextView) findViewById(R.id.sproducttype);
			sproducttype.setText(productInfo.getPtype());
			// 产品单价
			TextView sproductprice = (TextView) findViewById(R.id.sproductprice);
			sproductprice.setText(productInfo.getPprice());
			String[] content = getContent().split("b;");
			int sum1 = 0;
			int sum2 = 0;
			for (int i = 0; i < content.length; i++) {
				if (null != content[i] && !"".equals(content[i])) {
					sum1 += Integer.parseInt(content[i]);
					sum2++;
				}
			}
			// 主数量
			TextView sproductsum1 = (TextView) findViewById(R.id.sproductsum1);
			sproductsum1.setText(String.valueOf(sum1)
					+ productInfo.getSmeasure1());
			// 辅数量
			TextView sproductsum2 = (TextView) findViewById(R.id.sproductsum2);
			sproductsum2.setText(String.valueOf(sum2)
					+ productInfo.getSmeasure2());
			// 总价格
			TextView sproductcount = (TextView) findViewById(R.id.sproductcount);
			DecimalFormat df = new DecimalFormat("#.##");
			double count = Double.parseDouble(productInfo.getPprice()) * sum1;
			sproductcount.setText(df.format(count));
		}

		public void onNothingSelected(AdapterView<?> arg0) {
		}
	}
*/
	/**
	 * 搜索字段修改
	 */
	class AutoCompleteFocusChangeListener implements OnFocusChangeListener{

		@Override
		public void onFocusChange(View v, boolean hasFocus) {
			// TODO Auto-generated method stub
			if(!hasFocus){
				AutoCompleteTextView completeTextView1= (AutoCompleteTextView)findViewById(R.id.autoCompleteTextView1);
				for (int i = 0; i < arrCustomer.length; i++) {
					if(arrCustomer[i].getCname().equals(completeTextView1.getText().toString())){
						CustomerInfo cusTemp = arrCustomer[i];
						TextView saddress = (TextView) findViewById(R.id.saddress);
						saddress.setText(cusTemp.getCaddress());
						TextView scontact = (TextView) findViewById(R.id.scontact);
						scontact.setText(cusTemp.getCcontact());
						TextView sperson = (TextView) findViewById(R.id.sperson);
						sperson.setText(cusTemp.getCperson());
						break;
					}
				}
			}
		}
		
	}
	
	/**
	 * 
	 * @author alex.duan 通过会员选择 得到客户信息
	 */
	class SpinnerSelectedListener implements OnItemSelectedListener {

		public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
				long arg3) {
		/*	List<CustomerInfo> listCustomer = shipmentsDao
					.queryCustomerInfoVo(arrClerk[arg2]);
			arrCustomer = new CustomerInfo[listCustomer.size()];
			String[] str = new String[listCustomer.size()];
			int position = 0;
			for (int i = 0; i < listCustomer.size(); i++) {
				arrCustomer[i] = listCustomer.get(i);
				str[i] = listCustomer.get(i).getCname();
				if (listCustomer.get(i).getCname()
						.equals(shipmentsVo.getScustomer1())) {
					position = i;
				}
			}
			// 点击会员选择
			Spinner spinner = (Spinner) findViewById(R.id.scustomer1);
			// 将可选内容与ArrayAdapter连接起来
			ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(
					ViewActivity.this, android.R.layout.simple_spinner_item,
					str);
			// 设置下拉列表的风格
			adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
			// 将adapter 添加到spinner中
			spinner.setAdapter(adapter1);
			// 添加事件Spinner事件监听
			spinner.setOnItemSelectedListener(new SpinnerSelectedListener1());
			// 设置默认值
			spinner.setVisibility(View.VISIBLE);
			spinner.setSelection(position);*/
		}

		public void onNothingSelected(AdapterView<?> arg0) {

		}

		/**
		 * @author alex.duan 通过客户信息 得到该客户的联系方式 联系人等
		 */
		class SpinnerSelectedListener1 implements OnItemSelectedListener {

			public void onItemSelected(AdapterView<?> arg0, View arg1,
					int arg2, long arg3) {
				// 显示客户的联系方式之类的
				CustomerInfo cusTemp = arrCustomer[arg2];
				TextView saddress = (TextView) findViewById(R.id.saddress);
				saddress.setText(cusTemp.getCaddress());
				TextView scontact = (TextView) findViewById(R.id.scontact);
				scontact.setText(cusTemp.getCcontact());
				TextView sperson = (TextView) findViewById(R.id.sperson);
				sperson.setText(cusTemp.getCperson());
			}

			public void onNothingSelected(AdapterView<?> arg0) {
			}
		}

	}

	private boolean update() {
		if(true){
			// 显示客户的联系方式之类的
			//ProductVo productInfo = productInfoDefault;
			// 产品类型
			//TextView sproducttype = (TextView) findViewById(R.id.sproducttype);
			//sproducttype.setText(productInfo.getPtype());
			// 产品单价
			EditText sproductprice = (EditText) findViewById(R.id.sproductprice);
			//sproductprice.setText(productInfo.getPprice());
			String[] content = getContent().split("b;");
			double sum1 = 0;
			double sum2 = 0;
			for (int i = 0; i < content.length; i++) {
				if (null != content[i] && !"".equals(content[i])) {
					sum1 += Double.parseDouble(content[i]);
					sum2++;
				}
			}
			// 主数量
			TextView sproductsum1 = (TextView) findViewById(R.id.sproductsum1);
			sproductsum1.setText(String.valueOf(sum1)
					+ "米");
			// 辅数量
			TextView sproductsum2 = (TextView) findViewById(R.id.sproductsum2);
			sproductsum2.setText(String.valueOf(sum2)
					+ "匹");
			String price = sproductprice.getText().toString();
			if(null!= price && !"".equals(price)){
				// 总价格
				TextView sproductcount = (TextView) findViewById(R.id.sproductcount);
				DecimalFormat df = new DecimalFormat("#.##");
				double count = Double.parseDouble(price) * sum1;
				sproductcount.setText(df.format(count));
			}
		}
		
		
		TextView scodeEt = (TextView) findViewById(R.id.scode);
		String scode = scodeEt.getText().toString();

		TextView sdateEt = (TextView) findViewById(R.id.sdate);
		String sdate = sdateEt.getText().toString();

		

		AutoCompleteTextView completeTextView1 = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1);
		String scustomer1 = completeTextView1.getText().toString();
		AutoCompleteTextView completeTextView2 = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView2);
		String scustomer2 = completeTextView2.getText().toString();
		EditText spinnerProductInfo = (EditText) findViewById(R.id.sproductname);
		String sproductname = spinnerProductInfo.getText().toString();
		Spinner spinnerShipInfo = (Spinner) findViewById(R.id.scompany);
		String scompany = spinnerShipInfo.getSelectedItem().toString();
		Spinner spinner3 = (Spinner) findViewById(R.id.sclerk);
		String sclerk = spinner3.getSelectedItem().toString();

		TextView saddressEt = (TextView) findViewById(R.id.saddress);
		String saddress = saddressEt.getText().toString();

		TextView spersonEt = (TextView) findViewById(R.id.sperson);
		String sperson = spersonEt.getText().toString();

		TextView scontactEt = (TextView) findViewById(R.id.scontact);
		String scontact = scontactEt.getText().toString();

		EditText contentnumsEt = (EditText) findViewById(R.id.contentnums);
		String contentnums = contentnumsEt.getText().toString();
		EditText sproducttypeEt = (EditText) findViewById(R.id.sproducttype);
		String sproducttype = sproducttypeEt.getText().toString();

		EditText wuliuinfoEt = (EditText) findViewById(R.id.wuliuinfo);
		String wuliuinfo = wuliuinfoEt.getText().toString();
		
		TextView sproductsum2Et = (TextView) findViewById(R.id.sproductsum2);
		String sproductsum2 = sproductsum2Et.getText().toString();

		TextView sproductsum1Et = (TextView) findViewById(R.id.sproductsum1);
		String sproductsum1 = sproductsum1Et.getText().toString();

		EditText sproductpriceEt = (EditText) findViewById(R.id.sproductprice);
		String sproductprice = sproductpriceEt.getText().toString();

		TextView sproductcountEt = (TextView) findViewById(R.id.sproductcount);
		String sproductcount = sproductcountEt.getText().toString();

		String content = this.getContent();

		shipmentsDao = new ShipmentsDao(getApplicationContext());
		ShipmentsVo shipmentsVoTemp = new ShipmentsVo();
		shipmentsVoTemp.setSaddress(saddress);
		shipmentsVoTemp.setSclerk(sclerk);
		shipmentsVoTemp.setScode(scode);
		shipmentsVoTemp.setScompany(scompany);
		shipmentsVoTemp.setScontact(scontact);
		shipmentsVoTemp.setScontent(content);
		shipmentsVoTemp.setScustomer1(scustomer1);
		shipmentsVoTemp.setScustomer2(scustomer2);
		SharedPreferences userInfo = getSharedPreferences("user_info", 0);
		String uname = userInfo.getString("uname", "");
		shipmentsVoTemp.setUsername(uname);
		shipmentsVoTemp.setSdate(sdate);
		shipmentsVoTemp.setSperson(sperson);
		shipmentsVoTemp.setSproductcount(sproductcount);
		shipmentsVoTemp.setSproductname(sproductname);
		shipmentsVoTemp.setSproductprice(sproductprice);
		shipmentsVoTemp.setSproductsum1(sproductsum1);
		shipmentsVoTemp.setSproductsum2(sproductsum2);
		shipmentsVoTemp.setSproducttype(sproducttype);
		shipmentsVoTemp.setWuliuinfo(wuliuinfo);
		shipmentsVoTemp.setContentnums(contentnums);
		return shipmentsDao.updateShipmentsVo(shipmentsVoTemp,
				shipmentsVo.getSid());
	}

	/**
	 * 这个方法有多么2b，只有看了源码的人才知道哈。
	 * 
	 * @return
	 */
	private String getContent() {
		StringBuffer strb = new StringBuffer();
		EditText content1Et = (EditText) findViewById(R.id.content1);
		String content1 = content1Et.getText().toString();
		strb.append(content1);
		strb.append("b;");
		EditText content2Et = (EditText) findViewById(R.id.content2);
		String content2 = content2Et.getText().toString();
		strb.append(content2);
		strb.append("b;");
		EditText content3Et = (EditText) findViewById(R.id.content3);
		String content3 = content3Et.getText().toString();
		strb.append(content3);
		strb.append("b;");
		EditText content4Et = (EditText) findViewById(R.id.content4);
		String content4 = content4Et.getText().toString();
		strb.append(content4);
		strb.append("b;");
		EditText content5Et = (EditText) findViewById(R.id.content5);
		String content5 = content5Et.getText().toString();
		strb.append(content5);
		strb.append("b;");
		EditText content6Et = (EditText) findViewById(R.id.content6);
		String content6 = content6Et.getText().toString();
		strb.append(content6);
		strb.append("b;");
		EditText content7Et = (EditText) findViewById(R.id.content7);
		String content7 = content7Et.getText().toString();
		strb.append(content7);
		strb.append("b;");
		EditText content8Et = (EditText) findViewById(R.id.content8);
		String content8 = content8Et.getText().toString();
		strb.append(content8);
		strb.append("b;");
		EditText content9Et = (EditText) findViewById(R.id.content9);
		String content9 = content9Et.getText().toString();
		strb.append(content9);
		strb.append("b;");
		EditText content10Et = (EditText) findViewById(R.id.content10);
		String content10 = content10Et.getText().toString();
		strb.append(content10);
		strb.append("b;");
		EditText content11Et = (EditText) findViewById(R.id.content11);
		String content11 = content11Et.getText().toString();
		strb.append(content11);
		strb.append("b;");
		EditText content12Et = (EditText) findViewById(R.id.content12);
		String content12 = content12Et.getText().toString();
		strb.append(content12);
		strb.append("b;");
		EditText content13Et = (EditText) findViewById(R.id.content13);
		String content13 = content13Et.getText().toString();
		strb.append(content13);
		strb.append("b;");
		EditText content14Et = (EditText) findViewById(R.id.content14);
		String content14 = content14Et.getText().toString();
		strb.append(content14);
		strb.append("b;");
		EditText content15Et = (EditText) findViewById(R.id.content15);
		String content15 = content15Et.getText().toString();
		strb.append(content15);
		strb.append("b;");
		EditText content16Et = (EditText) findViewById(R.id.content16);
		String content16 = content16Et.getText().toString();
		strb.append(content16);
		strb.append("b;");
		EditText content17Et = (EditText) findViewById(R.id.content17);
		String content17 = content17Et.getText().toString();
		strb.append(content17);
		strb.append("b;");
		EditText content18Et = (EditText) findViewById(R.id.content18);
		String content18 = content18Et.getText().toString();
		strb.append(content18);
		strb.append("b;");
		EditText content19Et = (EditText) findViewById(R.id.content19);
		String content19 = content19Et.getText().toString();
		strb.append(content19);
		strb.append("b;");
		EditText content20Et = (EditText) findViewById(R.id.content20);
		String content20 = content20Et.getText().toString();
		strb.append(content20);
		strb.append("b;");
		EditText content21Et = (EditText) findViewById(R.id.content21);
		String content21 = content21Et.getText().toString();
		strb.append(content21);
		strb.append("b;");
		EditText content22Et = (EditText) findViewById(R.id.content22);
		String content22 = content22Et.getText().toString();
		strb.append(content22);
		strb.append("b;");
		EditText content23Et = (EditText) findViewById(R.id.content23);
		String content23 = content23Et.getText().toString();
		strb.append(content23);
		strb.append("b;");
		EditText content24Et = (EditText) findViewById(R.id.content24);
		String content24 = content24Et.getText().toString();
		strb.append(content24);
		strb.append("b;");
		EditText content25Et = (EditText) findViewById(R.id.content25);
		String content25 = content25Et.getText().toString();
		strb.append(content25);
		strb.append("b;");
		EditText content26Et = (EditText) findViewById(R.id.content26);
		String content26 = content26Et.getText().toString();
		strb.append(content26);
		strb.append("b;");
		EditText content27Et = (EditText) findViewById(R.id.content27);
		String content27 = content27Et.getText().toString();
		strb.append(content27);
		strb.append("b;");
		EditText content28Et = (EditText) findViewById(R.id.content28);
		String content28 = content28Et.getText().toString();
		strb.append(content28);
		strb.append("b;");
		EditText content29Et = (EditText) findViewById(R.id.content29);
		String content29 = content29Et.getText().toString();
		strb.append(content29);
		strb.append("b;");
		EditText content30Et = (EditText) findViewById(R.id.content30);
		String content30 = content30Et.getText().toString();
		strb.append(content30);
		strb.append("b;");
		EditText content31Et = (EditText) findViewById(R.id.content31);
		String content31 = content31Et.getText().toString();
		strb.append(content31);
		strb.append("b;");
		EditText content32Et = (EditText) findViewById(R.id.content32);
		String content32 = content32Et.getText().toString();
		strb.append(content32);
		strb.append("b;");
		EditText content33Et = (EditText) findViewById(R.id.content33);
		String content33 = content33Et.getText().toString();
		strb.append(content33);
		strb.append("b;");
		EditText content34Et = (EditText) findViewById(R.id.content34);
		String content34 = content34Et.getText().toString();
		strb.append(content34);
		strb.append("b;");
		EditText content35Et = (EditText) findViewById(R.id.content35);
		String content35 = content35Et.getText().toString();
		strb.append(content35);
		strb.append("b;");
		EditText content36Et = (EditText) findViewById(R.id.content36);
		String content36 = content36Et.getText().toString();
		strb.append(content36);
		strb.append("b;");
		EditText content37Et = (EditText) findViewById(R.id.content37);
		String content37 = content37Et.getText().toString();
		strb.append(content37);
		strb.append("b;");
		EditText content38Et = (EditText) findViewById(R.id.content38);
		String content38 = content38Et.getText().toString();
		strb.append(content38);
		strb.append("b;");
		EditText content39Et = (EditText) findViewById(R.id.content39);
		String content39 = content39Et.getText().toString();
		strb.append(content39);
		strb.append("b;");
		EditText content40Et = (EditText) findViewById(R.id.content40);
		String content40 = content40Et.getText().toString();
		strb.append(content40);
		strb.append("b;");
		EditText content41Et = (EditText) findViewById(R.id.content41);
		String content41 = content41Et.getText().toString();
		strb.append(content41);
		strb.append("b;");
		EditText content42Et = (EditText) findViewById(R.id.content42);
		String content42 = content42Et.getText().toString();
		strb.append(content42);
		strb.append("b;");
		EditText content43Et = (EditText) findViewById(R.id.content43);
		String content43 = content43Et.getText().toString();
		strb.append(content43);
		strb.append("b;");
		EditText content44Et = (EditText) findViewById(R.id.content44);
		String content44 = content44Et.getText().toString();
		strb.append(content44);
		strb.append("b;");
		EditText content45Et = (EditText) findViewById(R.id.content45);
		String content45 = content45Et.getText().toString();
		strb.append(content45);
		strb.append("b;");
		EditText content46Et = (EditText) findViewById(R.id.content46);
		String content46 = content46Et.getText().toString();
		strb.append(content46);
		strb.append("b;");
		EditText content47Et = (EditText) findViewById(R.id.content47);
		String content47 = content47Et.getText().toString();
		strb.append(content47);
		strb.append("b;");
		EditText content48Et = (EditText) findViewById(R.id.content48);
		String content48 = content48Et.getText().toString();
		strb.append(content48);
		strb.append("b;");
		EditText content49Et = (EditText) findViewById(R.id.content49);
		String content49 = content49Et.getText().toString();
		strb.append(content49);
		strb.append("b;");
		EditText content50Et = (EditText) findViewById(R.id.content50);
		String content50 = content50Et.getText().toString();
		strb.append(content50);
		strb.append("b;");
		EditText content51Et = (EditText) findViewById(R.id.content51);
		String content51 = content51Et.getText().toString();
		strb.append(content51);
		strb.append("b;");
		EditText content52Et = (EditText) findViewById(R.id.content52);
		String content52 = content52Et.getText().toString();
		strb.append(content52);
		strb.append("b;");
		EditText content53Et = (EditText) findViewById(R.id.content53);
		String content53 = content53Et.getText().toString();
		strb.append(content53);
		strb.append("b;");
		EditText content54Et = (EditText) findViewById(R.id.content54);
		String content54 = content54Et.getText().toString();
		strb.append(content54);
		strb.append("b;");
		EditText content55Et = (EditText) findViewById(R.id.content55);
		String content55 = content55Et.getText().toString();
		strb.append(content55);
		strb.append("b;");
		EditText content56Et = (EditText) findViewById(R.id.content56);
		String content56 = content56Et.getText().toString();
		strb.append(content56);
		strb.append("b;");
		EditText content57Et = (EditText) findViewById(R.id.content57);
		String content57 = content57Et.getText().toString();
		strb.append(content57);
		strb.append("b;");
		EditText content58Et = (EditText) findViewById(R.id.content58);
		String content58 = content58Et.getText().toString();
		strb.append(content58);
		strb.append("b;");
		EditText content59Et = (EditText) findViewById(R.id.content59);
		String content59 = content59Et.getText().toString();
		strb.append(content59);
		strb.append("b;");
		EditText content60Et = (EditText) findViewById(R.id.content60);
		String content60 = content60Et.getText().toString();
		strb.append(content60);
		strb.append("b;");
		EditText content61Et = (EditText) findViewById(R.id.content61);
		String content61 = content61Et.getText().toString();
		strb.append(content61);
		strb.append("b;");
		EditText content62Et = (EditText) findViewById(R.id.content62);
		String content62 = content62Et.getText().toString();
		strb.append(content62);
		strb.append("b;");
		EditText content63Et = (EditText) findViewById(R.id.content63);
		String content63 = content63Et.getText().toString();
		strb.append(content63);
		strb.append("b;");
		EditText content64Et = (EditText) findViewById(R.id.content64);
		String content64 = content64Et.getText().toString();
		strb.append(content64);
		strb.append("b;");
		EditText content65Et = (EditText) findViewById(R.id.content65);
		String content65 = content65Et.getText().toString();
		strb.append(content65);
		strb.append("b;");
		EditText content66Et = (EditText) findViewById(R.id.content66);
		String content66 = content66Et.getText().toString();
		strb.append(content66);
		strb.append("b;");
		EditText content67Et = (EditText) findViewById(R.id.content67);
		String content67 = content67Et.getText().toString();
		strb.append(content67);
		strb.append("b;");
		EditText content68Et = (EditText) findViewById(R.id.content68);
		String content68 = content68Et.getText().toString();
		strb.append(content68);
		strb.append("b;");
		EditText content69Et = (EditText) findViewById(R.id.content69);
		String content69 = content69Et.getText().toString();
		strb.append(content69);
		strb.append("b;");
		EditText content70Et = (EditText) findViewById(R.id.content70);
		String content70 = content70Et.getText().toString();
		strb.append(content70);
		strb.append("b;");
		EditText content71Et = (EditText) findViewById(R.id.content71);
		String content71 = content71Et.getText().toString();
		strb.append(content71);
		strb.append("b;");
		EditText content72Et = (EditText) findViewById(R.id.content72);
		String content72 = content72Et.getText().toString();
		strb.append(content72);
		strb.append("b;");
		EditText content73Et = (EditText) findViewById(R.id.content73);
		String content73 = content73Et.getText().toString();
		strb.append(content73);
		strb.append("b;");
		EditText content74Et = (EditText) findViewById(R.id.content74);
		String content74 = content74Et.getText().toString();
		strb.append(content74);
		strb.append("b;");
		EditText content75Et = (EditText) findViewById(R.id.content75);
		String content75 = content75Et.getText().toString();
		strb.append(content75);
		strb.append("b;");
		EditText content76Et = (EditText) findViewById(R.id.content76);
		String content76 = content76Et.getText().toString();
		strb.append(content76);
		strb.append("b;");
		EditText content77Et = (EditText) findViewById(R.id.content77);
		String content77 = content77Et.getText().toString();
		strb.append(content77);
		strb.append("b;");
		EditText content78Et = (EditText) findViewById(R.id.content78);
		String content78 = content78Et.getText().toString();
		strb.append(content78);
		strb.append("b;");
		EditText content79Et = (EditText) findViewById(R.id.content79);
		String content79 = content79Et.getText().toString();
		strb.append(content79);
		strb.append("b;");
		EditText content80Et = (EditText) findViewById(R.id.content80);
		String content80 = content80Et.getText().toString();
		strb.append(content80);
		strb.append("b;");
		EditText content81Et = (EditText) findViewById(R.id.content81);
		String content81 = content81Et.getText().toString();
		strb.append(content81);
		strb.append("b;");
		EditText content82Et = (EditText) findViewById(R.id.content82);
		String content82 = content82Et.getText().toString();
		strb.append(content82);
		strb.append("b;");
		EditText content83Et = (EditText) findViewById(R.id.content83);
		String content83 = content83Et.getText().toString();
		strb.append(content83);
		strb.append("b;");
		EditText content84Et = (EditText) findViewById(R.id.content84);
		String content84 = content84Et.getText().toString();
		strb.append(content84);
		strb.append("b;");
		EditText content85Et = (EditText) findViewById(R.id.content85);
		String content85 = content85Et.getText().toString();
		strb.append(content85);
		strb.append("b;");
		EditText content86Et = (EditText) findViewById(R.id.content86);
		String content86 = content86Et.getText().toString();
		strb.append(content86);
		strb.append("b;");
		EditText content87Et = (EditText) findViewById(R.id.content87);
		String content87 = content87Et.getText().toString();
		strb.append(content87);
		strb.append("b;");
		EditText content88Et = (EditText) findViewById(R.id.content88);
		String content88 = content88Et.getText().toString();
		strb.append(content88);
		strb.append("b;");
		EditText content89Et = (EditText) findViewById(R.id.content89);
		String content89 = content89Et.getText().toString();
		strb.append(content89);
		strb.append("b;");
		EditText content90Et = (EditText) findViewById(R.id.content90);
		String content90 = content90Et.getText().toString();
		strb.append(content90);
		strb.append("b;");
		EditText content91Et = (EditText) findViewById(R.id.content91);
		String content91 = content91Et.getText().toString();
		strb.append(content91);
		strb.append("b;");
		EditText content92Et = (EditText) findViewById(R.id.content92);
		String content92 = content92Et.getText().toString();
		strb.append(content92);
		strb.append("b;");
		EditText content93Et = (EditText) findViewById(R.id.content93);
		String content93 = content93Et.getText().toString();
		strb.append(content93);
		strb.append("b;");
		EditText content94Et = (EditText) findViewById(R.id.content94);
		String content94 = content94Et.getText().toString();
		strb.append(content94);
		strb.append("b;");
		EditText content95Et = (EditText) findViewById(R.id.content95);
		String content95 = content95Et.getText().toString();
		strb.append(content95);
		strb.append("b;");
		EditText content96Et = (EditText) findViewById(R.id.content96);
		String content96 = content96Et.getText().toString();
		strb.append(content96);
		strb.append("b;");
		EditText content97Et = (EditText) findViewById(R.id.content97);
		String content97 = content97Et.getText().toString();
		strb.append(content97);
		strb.append("b;");
		EditText content98Et = (EditText) findViewById(R.id.content98);
		String content98 = content98Et.getText().toString();
		strb.append(content98);
		strb.append("b;");
		EditText content99Et = (EditText) findViewById(R.id.content99);
		String content99 = content99Et.getText().toString();
		strb.append(content99);
		strb.append("b;");
		EditText content100Et = (EditText) findViewById(R.id.content100);
		String content100 = content100Et.getText().toString();
		strb.append(content100);
		strb.append("b;");
		return strb.toString();
	}

	private void setContent(String[] contentArr) {
		for (int i = 1; i <= contentArr.length; i++) {
			String content1 = contentArr[i - 1];
			if (!"b".equals(content1)) {
				String content = content1.split("b")[0];
				switch (i) {
				case 1:
					EditText content1Et = (EditText) findViewById(R.id.content1);
					content1Et.setText(content);
					break;
				case 2:
					EditText content2Et = (EditText) findViewById(R.id.content2);
					content2Et.setText(content);
					break;
				case 3:
					EditText content3Et = (EditText) findViewById(R.id.content3);
					content3Et.setText(content);
					break;
				case 4:
					EditText content4Et = (EditText) findViewById(R.id.content4);
					content4Et.setText(content);
					break;
				case 5:
					EditText content5Et = (EditText) findViewById(R.id.content5);
					content5Et.setText(content);
					break;
				case 6:
					EditText content6Et = (EditText) findViewById(R.id.content6);
					content6Et.setText(content);
					break;
				case 7:
					EditText content7Et = (EditText) findViewById(R.id.content7);
					content7Et.setText(content);
					break;
				case 8:
					EditText content8Et = (EditText) findViewById(R.id.content8);
					content8Et.setText(content);
					break;
				case 9:
					EditText content9Et = (EditText) findViewById(R.id.content9);
					content9Et.setText(content);
					break;
				case 10:
					EditText content10Et = (EditText) findViewById(R.id.content10);
					content10Et.setText(content);
					break;
				case 11:
					EditText content11Et = (EditText) findViewById(R.id.content11);
					content11Et.setText(content);
					break;
				case 12:
					EditText content12Et = (EditText) findViewById(R.id.content12);
					content12Et.setText(content);
					break;
				case 13:
					EditText content13Et = (EditText) findViewById(R.id.content13);
					content13Et.setText(content);
					break;
				case 14:
					EditText content14Et = (EditText) findViewById(R.id.content14);
					content14Et.setText(content);
					break;
				case 15:
					EditText content15Et = (EditText) findViewById(R.id.content15);
					content15Et.setText(content);
					break;
				case 16:
					EditText content16Et = (EditText) findViewById(R.id.content16);
					content16Et.setText(content);
					break;
				case 17:
					EditText content17Et = (EditText) findViewById(R.id.content17);
					content17Et.setText(content);
					break;
				case 18:
					EditText content18Et = (EditText) findViewById(R.id.content18);
					content18Et.setText(content);
					break;
				case 19:
					EditText content19Et = (EditText) findViewById(R.id.content19);
					content19Et.setText(content);
					break;
				case 20:
					EditText content20Et = (EditText) findViewById(R.id.content20);
					content20Et.setText(content);
					break;
				case 21:
					EditText content21Et = (EditText) findViewById(R.id.content21);
					content21Et.setText(content);
					break;
				case 22:
					EditText content22Et = (EditText) findViewById(R.id.content22);
					content22Et.setText(content);
					break;
				case 23:
					EditText content23Et = (EditText) findViewById(R.id.content23);
					content23Et.setText(content);
					break;
				case 24:
					EditText content24Et = (EditText) findViewById(R.id.content24);
					content24Et.setText(content);
					break;
				case 25:
					EditText content25Et = (EditText) findViewById(R.id.content25);
					content25Et.setText(content);
					break;
				case 26:
					EditText content26Et = (EditText) findViewById(R.id.content26);
					content26Et.setText(content);
					break;
				case 27:
					EditText content27Et = (EditText) findViewById(R.id.content27);
					content27Et.setText(content);
					break;
				case 28:
					EditText content28Et = (EditText) findViewById(R.id.content28);
					content28Et.setText(content);
					break;
				case 29:
					EditText content29Et = (EditText) findViewById(R.id.content29);
					content29Et.setText(content);
					break;
				case 30:
					EditText content30Et = (EditText) findViewById(R.id.content30);
					content30Et.setText(content);
					break;
				case 31:
					EditText content31Et = (EditText) findViewById(R.id.content31);
					content31Et.setText(content);
					break;
				case 32:
					EditText content32Et = (EditText) findViewById(R.id.content32);
					content32Et.setText(content);
					break;
				case 33:
					EditText content33Et = (EditText) findViewById(R.id.content33);
					content33Et.setText(content);
					break;
				case 34:
					EditText content34Et = (EditText) findViewById(R.id.content34);
					content34Et.setText(content);
					break;
				case 35:
					EditText content35Et = (EditText) findViewById(R.id.content35);
					content35Et.setText(content);
					break;
				case 36:
					EditText content36Et = (EditText) findViewById(R.id.content36);
					content36Et.setText(content);
					break;
				case 37:
					EditText content37Et = (EditText) findViewById(R.id.content37);
					content37Et.setText(content);
					break;
				case 38:
					EditText content38Et = (EditText) findViewById(R.id.content38);
					content38Et.setText(content);
					break;
				case 39:
					EditText content39Et = (EditText) findViewById(R.id.content39);
					content39Et.setText(content);
					break;
				case 40:
					EditText content40Et = (EditText) findViewById(R.id.content40);
					content40Et.setText(content);
					break;
				case 41:
					EditText content41Et = (EditText) findViewById(R.id.content41);
					content41Et.setText(content);
					break;
				case 42:
					EditText content42Et = (EditText) findViewById(R.id.content42);
					content42Et.setText(content);
					break;
				case 43:
					EditText content43Et = (EditText) findViewById(R.id.content43);
					content43Et.setText(content);
					break;
				case 44:
					EditText content44Et = (EditText) findViewById(R.id.content44);
					content44Et.setText(content);
					break;
				case 45:
					EditText content45Et = (EditText) findViewById(R.id.content45);
					content45Et.setText(content);
					break;
				case 46:
					EditText content46Et = (EditText) findViewById(R.id.content46);
					content46Et.setText(content);
					break;
				case 47:
					EditText content47Et = (EditText) findViewById(R.id.content47);
					content47Et.setText(content);
					break;
				case 48:
					EditText content48Et = (EditText) findViewById(R.id.content48);
					content48Et.setText(content);
					break;
				case 49:
					EditText content49Et = (EditText) findViewById(R.id.content49);
					content49Et.setText(content);
					break;
				case 50:
					EditText content50Et = (EditText) findViewById(R.id.content50);
					content50Et.setText(content);
					break;
				case 51:
					EditText content51Et = (EditText) findViewById(R.id.content51);
					content51Et.setText(content);
					break;
				case 52:
					EditText content52Et = (EditText) findViewById(R.id.content52);
					content52Et.setText(content);
					break;
				case 53:
					EditText content53Et = (EditText) findViewById(R.id.content53);
					content53Et.setText(content);
					break;
				case 54:
					EditText content54Et = (EditText) findViewById(R.id.content54);
					content54Et.setText(content);
					break;
				case 55:
					EditText content55Et = (EditText) findViewById(R.id.content55);
					content55Et.setText(content);
					break;
				case 56:
					EditText content56Et = (EditText) findViewById(R.id.content56);
					content56Et.setText(content);
					break;
				case 57:
					EditText content57Et = (EditText) findViewById(R.id.content57);
					content57Et.setText(content);
					break;
				case 58:
					EditText content58Et = (EditText) findViewById(R.id.content58);
					content58Et.setText(content);
					break;
				case 59:
					EditText content59Et = (EditText) findViewById(R.id.content59);
					content59Et.setText(content);
					break;
				case 60:
					EditText content60Et = (EditText) findViewById(R.id.content60);
					content60Et.setText(content);
					break;
				case 61:
					EditText content61Et = (EditText) findViewById(R.id.content61);
					content61Et.setText(content);
					break;
				case 62:
					EditText content62Et = (EditText) findViewById(R.id.content62);
					content62Et.setText(content);
					break;
				case 63:
					EditText content63Et = (EditText) findViewById(R.id.content63);
					content63Et.setText(content);
					break;
				case 64:
					EditText content64Et = (EditText) findViewById(R.id.content64);
					content64Et.setText(content);
					break;
				case 65:
					EditText content65Et = (EditText) findViewById(R.id.content65);
					content65Et.setText(content);
					break;
				case 66:
					EditText content66Et = (EditText) findViewById(R.id.content66);
					content66Et.setText(content);
					break;
				case 67:
					EditText content67Et = (EditText) findViewById(R.id.content67);
					content67Et.setText(content);
					break;
				case 68:
					EditText content68Et = (EditText) findViewById(R.id.content68);
					content68Et.setText(content);
					break;
				case 69:
					EditText content69Et = (EditText) findViewById(R.id.content69);
					content69Et.setText(content);
					break;
				case 70:
					EditText content70Et = (EditText) findViewById(R.id.content70);
					content70Et.setText(content);
					break;
				case 71:
					EditText content71Et = (EditText) findViewById(R.id.content71);
					content71Et.setText(content);
					break;
				case 72:
					EditText content72Et = (EditText) findViewById(R.id.content72);
					content72Et.setText(content);
					break;
				case 73:
					EditText content73Et = (EditText) findViewById(R.id.content73);
					content73Et.setText(content);
					break;
				case 74:
					EditText content74Et = (EditText) findViewById(R.id.content74);
					content74Et.setText(content);
					break;
				case 75:
					EditText content75Et = (EditText) findViewById(R.id.content75);
					content75Et.setText(content);
					break;
				case 76:
					EditText content76Et = (EditText) findViewById(R.id.content76);
					content76Et.setText(content);
					break;
				case 77:
					EditText content77Et = (EditText) findViewById(R.id.content77);
					content77Et.setText(content);
					break;
				case 78:
					EditText content78Et = (EditText) findViewById(R.id.content78);
					content78Et.setText(content);
					break;
				case 79:
					EditText content79Et = (EditText) findViewById(R.id.content79);
					content79Et.setText(content);
					break;
				case 80:
					EditText content80Et = (EditText) findViewById(R.id.content80);
					content80Et.setText(content);
					break;
				case 81:
					EditText content81Et = (EditText) findViewById(R.id.content81);
					content81Et.setText(content);
					break;
				case 82:
					EditText content82Et = (EditText) findViewById(R.id.content82);
					content82Et.setText(content);
					break;
				case 83:
					EditText content83Et = (EditText) findViewById(R.id.content83);
					content83Et.setText(content);
					break;
				case 84:
					EditText content84Et = (EditText) findViewById(R.id.content84);
					content84Et.setText(content);
					break;
				case 85:
					EditText content85Et = (EditText) findViewById(R.id.content85);
					content85Et.setText(content);
					break;
				case 86:
					EditText content86Et = (EditText) findViewById(R.id.content86);
					content86Et.setText(content);
					break;
				case 87:
					EditText content87Et = (EditText) findViewById(R.id.content87);
					content87Et.setText(content);
					break;
				case 88:
					EditText content88Et = (EditText) findViewById(R.id.content88);
					content88Et.setText(content);
					break;
				case 89:
					EditText content89Et = (EditText) findViewById(R.id.content89);
					content89Et.setText(content);
					break;
				case 90:
					EditText content90Et = (EditText) findViewById(R.id.content90);
					content90Et.setText(content);
					break;
				case 91:
					EditText content91Et = (EditText) findViewById(R.id.content91);
					content91Et.setText(content);
					break;
				case 92:
					EditText content92Et = (EditText) findViewById(R.id.content92);
					content92Et.setText(content);
					break;
				case 93:
					EditText content93Et = (EditText) findViewById(R.id.content93);
					content93Et.setText(content);
					break;
				case 94:
					EditText content94Et = (EditText) findViewById(R.id.content94);
					content94Et.setText(content);
					break;
				case 95:
					EditText content95Et = (EditText) findViewById(R.id.content95);
					content95Et.setText(content);
					break;
				case 96:
					EditText content96Et = (EditText) findViewById(R.id.content96);
					content96Et.setText(content);
					break;
				case 97:
					EditText content97Et = (EditText) findViewById(R.id.content97);
					content97Et.setText(content);
					break;
				case 98:
					EditText content98Et = (EditText) findViewById(R.id.content98);
					content98Et.setText(content);
					break;
				case 99:
					EditText content99Et = (EditText) findViewById(R.id.content99);
					content99Et.setText(content);
					break;
				case 100:
					EditText content100Et = (EditText) findViewById(R.id.content100);
					content100Et.setText(content);
					break;
				}
			}
		}
	}

	private void setDateTime() {

		final Calendar c = Calendar.getInstance();

		mYear = c.get(Calendar.YEAR);

		mMonth = c.get(Calendar.MONTH);

		mDay = c.get(Calendar.DAY_OF_MONTH);

		updateDisplay();

	}

	/**
	 * 
	 * 更新日期
	 */

	private void updateDisplay() {

		showDate.setText(new StringBuilder().append(mYear).append(

		(mMonth + 1) < 10 ? "0" + (mMonth + 1) : (mMonth + 1)).append(

		(mDay < 10) ? "0" + mDay : mDay));

	}

	/**
	 * 
	 * 日期控件的事件
	 */

	private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() {

		public void onDateSet(DatePicker view, int year, int monthOfYear,

		int dayOfMonth) {

			mYear = year;

			mMonth = monthOfYear;

			mDay = dayOfMonth;

			updateDisplay();

		}

	};

	/**
	 * 
	 * 选择日期Button的事件处理
	 * 
	 * 
	 * 
	 * @author Raul
	 * 
	 * 
	 */

	class DateButtonOnClickListener implements

	android.view.View.OnClickListener {

		@Override
		public void onClick(View v) {
			Message msg = new Message();
			if (showDate.equals((EditText) v)) {
				msg.what = ViewActivity.SHOW_DATAPICK;
			}
			ViewActivity.this.saleHandler.sendMessage(msg);
		}

	}

	@Override
	protected Dialog onCreateDialog(int id) {

		switch (id) {

		case DATE_DIALOG_ID:

			return new DatePickerDialog(this, mDateSetListener, mYear, mMonth,

			mDay);

		}

		return null;

	}

	@Override
	protected void onPrepareDialog(int id, Dialog dialog) {

		switch (id) {

		case DATE_DIALOG_ID:

			((DatePickerDialog) dialog).updateDate(mYear, mMonth, mDay);

			break;

		}

	}

	/**
	 * 
	 * 处理日期控件的Handler
	 */

	Handler saleHandler = new Handler() {

		@Override
		public void handleMessage(Message msg) {

			switch (msg.what) {

			case ViewActivity.SHOW_DATAPICK:

				showDialog(DATE_DIALOG_ID);

				break;

			}

		}

	};
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
			Toast.makeText(getApplicationContext(), "请先保存内容",
					Toast.LENGTH_SHORT).show();
			return false;
		}else if(keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() >= 0){
			finish();
			// 跳转到查询页面
			Intent intent = new Intent(ViewActivity.this,
					ListActivity.class);
			startActivity(intent);
			return true;
		}
		return super.onKeyDown(keyCode, event);
	}
}
